using Pinwheel.Kernel;
using Pinwheel.LSerialize;

namespace Pinwheel.Service.Protocol
{
    [LSerializable]
    public partial struct Message : IMessage
    {
        public static readonly Message Empty = new Message();
    }
    
    [LSerializable]
    public partial struct Result : IMessage
    {
        public int Code;
        public string Info;
        public IMessage Message;

        public static readonly Result Success = new Result()
        {
            Code = 0,
            Info = "Success",
            Message = null!
        };
        
        public static readonly Result Failure = new Result()
        {
            Code = -1,
            Info = "Failure",
            Message = null!
        };

        public static Result Succeed(IMessage message)
        {
            return new Result()
            {
                Code = 0,
                Info = "Success",
                Message = message
            };
        }
        
        public static Result Failed(int code, string info)
        {
            return new Result()
            {
                Code = code,
                Info = info,
                Message = null!
            };
        }
    }
    
    [LSerializable]
    public partial struct Heartbeat : IMessage
    {
        public long Value;
    }
    
    [LSerializable]
    public partial struct Start : IMessage
    {
        public int Value1;
        public int Value2;
    }
    
    public partial struct Listen : IMessage
    {
        public int Port;
    }
    
    public partial struct Stop : IMessage
    {
    
    }
    
    public partial struct Test : IMessage
    {
        public int Value;
    }
}